

package body Impacts_Listes is

   function Plus_Proche_Impact (L : Impacts_Liste_Type) return T_Impact is
      Imp : T_Impact;
   begin
      if Integer (L.Length) > 0 then
         Imp := L.First_Element;
         for I in 2 .. Integer (L.Length) loop
            if L.Element (I).Dt < Imp.Dt then
               Imp := L.Element (I);
            end if;
         end loop;
      else
         Imp.Genre := Aucun;
      end if;
      return Imp;
   end Plus_Proche_Impact;

   procedure Decrementer_Dt (L : in out Impacts_Liste_Type; Decrement : Positive_Long_Float) is
      Imp : T_Impact;
   begin
      for I in 1 .. Integer (L.Length) loop
         Imp := L.Element (I);
         Imp.Dt := Imp.Dt - Decrement;
         L.Replace_Element (I, Imp);
      end loop;
   end Decrementer_Dt;

   procedure Supprimer_Et_Decrementer (L : in out Impacts_Liste_Type; Id1 : Natural; Id2 : Natural := 0; Dt : Long_Float := 0.0) is
      L2   : Impacts_Liste_Type;
      Imp  : T_Impact;
   begin
      for I in 1 .. Integer (L.Length) loop
         Imp := L.Element (I);
         if not (Imp.Id1 = Id1 or Imp.Id1 = Id2 or Imp.Id2 = Id1 or Imp.Id2 = Id2) then
            Imp.Dt := Imp.Dt - Dt;
            L2.Append (Imp);
         end if;
      end loop;
      L := L2;
   end Supprimer_Et_Decrementer;

end Impacts_Listes;
